Skip to main content
Glama
ZephyrDeng

mcp-server-gitlab

Gitlab Accept MR Tool

Accept and merge GitLab merge requests for specified projects with customizable options like commit messages, branch removal, and squash merging.

Instructions

接受并合并指定项目的合并请求,支持自定义合并选项。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fieldsNo需要返回的字段路径数组
mergeOptionsNo合并选项
mergeRequestIdYes合并请求 ID
projectIdYes项目 ID

Implementation Reference

  • Handler function that executes the tool: resolves project ID, performs GitLab API PUT to merge MR, filters response if needed, handles errors.
    async execute(args: unknown, context: Context<Record<string, unknown> | undefined>) {
      const typedArgs = args as {
        projectId: string | number;
        mergeRequestId: number;
        mergeOptions?: {
          mergeCommitMessage?: string;
          squash?: boolean;
          shouldRemoveSourceBranch?: boolean;
        };
        fields?: string[];
      };
      
      const { projectId: projectIdOrName, mergeRequestId, mergeOptions, fields } = typedArgs;
    
      try {
        const client = createGitlabClientFromContext(context);
        const resolvedProjectId = await client.resolveProjectId(projectIdOrName);
        if (!resolvedProjectId) {
          throw new Error(`无法解析项目 ID 或名称:${projectIdOrName}`);
        }
    
        const endpoint = `/projects/${encodeURIComponent(String(resolvedProjectId))}/merge_requests/${mergeRequestId}/merge`;
        const response = await client.apiRequest(endpoint, "PUT", undefined, mergeOptions);
    
        if (!client.isValidResponse(response)) {
          throw new Error(`GitLab API error: ${response?.message || 'Unknown error'}`);
        }
    
        if (fields) {
          const filteredResponse = filterResponseFields(response, fields);
          return {
            content: [{ type: "text", text: JSON.stringify(filteredResponse) }]
          } as ContentResult;
        }
        
        return {
          content: [{ type: "text", text: JSON.stringify(response) }]
        } as ContentResult;
      } catch (error: any) {
        return {
          content: [
            {
              type: "text",
              text: `GitLab MCP 工具调用异常:${error?.message || String(error)}`
            }
          ],
          isError: true
        };
      }
  • Zod schema defining input parameters: projectId, mergeRequestId, optional mergeOptions and fields.
    parameters: z.object({
      projectId: z.union([z.string(), z.number()]).describe("项目 ID 或名称"),
      mergeRequestId: z.number().describe("合并请求 ID"),
      mergeOptions: z.object({
        mergeCommitMessage: z.string().optional(),
        squash: z.boolean().optional(),
        shouldRemoveSourceBranch: z.boolean().optional(),
      }).optional().describe("合并选项"),
      fields: z.array(z.string()).optional().describe("需要返回的字段路径数组"),
    }),
  • GitlabAcceptMRTool is included in the fastmcpTools array, which is iterated over during tool registration.
    const fastmcpTools = [
      GitlabAcceptMRTool,
      GitlabCreateMRCommentTool,
      GitlabCreateMRTool,
      GitlabGetUserTasksTool,
      GitlabRawApiTool,
      GitlabSearchProjectDetailsTool,
      GitlabSearchUserProjectsTool,
      GitlabUpdateMRTool,
    ];
  • The registration logic in registerGitLabToolsForFastMCP that adds filtered tools from fastmcpTools to the FastMCP server.
    fastmcpTools.forEach(tool => {
      const standardizedName = toolNameMapping[tool.name as keyof typeof toolNameMapping];
      if (shouldRegisterTool(standardizedName as GitLabToolName, options.toolFilter)) {
        // GitLabTool is now fully compatible with FastMCP's base type, can be registered directly
        server.addTool(tool);
      }
  • Name mapping for the tool used in filtering during registration.
    [GitlabAcceptMRTool.name]: "Gitlab_Accept_MR_Tool",
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. While '接受并合并' implies a write operation that modifies the repository, it doesn't disclose critical behavioral traits: whether this requires specific permissions (e.g., maintainer role), if it's irreversible, potential side effects (e.g., branch deletion), rate limits, or what happens on failure. The mention of '自定义合并选项' (custom merge options) hints at configurability but lacks specifics.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose. It avoids redundancy and wastes no words, though it could be slightly more informative without sacrificing conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (a write operation with 4 parameters, nested objects, and no output schema) and lack of annotations, the description is incomplete. It doesn't explain return values, error conditions, or important behavioral context (e.g., merge strategies, permissions). For a tool that performs a significant repository action, this leaves critical gaps for an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 4 parameters. The description adds minimal value beyond the schema by mentioning '自定义合并选项' (custom merge options), which aligns with the 'mergeOptions' parameter but doesn't elaborate on semantics. With high schema coverage, the baseline is 3.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('接受并合并' - accept and merge) and the resource ('指定项目的合并请求' - specified project's merge request). It distinguishes from sibling tools like 'Gitlab Create MR Tool' and 'Gitlab Update MR Tool' by focusing on finalizing merge requests. However, it doesn't explicitly mention that this is for GitLab specifically (though the tool name implies it).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., merge request must be in a mergeable state), when not to use it (e.g., for draft MRs), or how it differs from sibling tools like 'Gitlab Update MR Tool' which might handle MR modifications without merging.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ZephyrDeng/mcp-server-gitlab'

If you have feedback or need assistance with the MCP directory API, please join our Discord server